package com.cszy.yydqbfq.ui.activity

import android.os.Bundle
import android.util.Log
import android.webkit.WebViewClient
import com.hbcysd.qybfq.databinding.ActivityHtmlBinding
import com.cszy.yydqbfq.base.BaseVMActivity

import com.cszy.yydqbfq.viewmodel.MainViewModel



class HtmlActivity : BaseVMActivity<MainViewModel, ActivityHtmlBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        mBinding.back.setOnClickListener { v -> finish() }
        val title = intent.getStringExtra("title")
        val url = intent.getStringExtra("url")

        //webView.loadUrl("file:///android_asset/"+url)
        try {
            if (url != null) {
                mBinding.web.loadUrl(url)
            }
            val settings = mBinding.web.settings
            settings.javaScriptEnabled = true
            // 设置缓存模式为不使用缓存，始终从网络加载
            settings.cacheMode = android.webkit.WebSettings.LOAD_NO_CACHE
            mBinding.web.webViewClient = WebViewClient()
            //binding.web.setDownloadListener(new MWebViewDownLoadListener());
        } catch (e: Exception) {
//            Log.e("hjwcs", e.message!!)
        }

        mBinding.tvTitle.setText(title)
    }

}